<?php
class Admin_AccountController extends Myh_Controller_Action
{
	
	protected $_arrParams;
	protected $_currentController;
	protected $_mainAction;
	
	public function init()
	{
		$this->_arrParams 			= $this->getRequest()->getParams();
		$this->_currentController 	= '/' . $this->_arrParams['module'] .
									  '/' . $this->_arrParams['controller'];
		$this->_mainAction 			= '/' . $this->_arrParams['module'] .
							 		  '/' . $this->_arrParams['controller'] . 
							 		  '/' . 'index';
		$this->view->arrParams 			= $this->_arrParams;
		$this->view->currentContrller 	= $this->_currentController; 
		$this->view->mainAction			= $this->_mainAction;
		$templatePath					= APP_PATH . '/design/admin/default/template';
		$this->loadTemplate($templatePath);
	}
	public function indexAction()
	{
		
	}
	public function accountsAction()
	{
		
	}
	public function roleAction()
	{
		
	}
	public function loginAction()
	{
		$templatePath					= APP_PATH . '/design/admin/default/template';
		$this->loadTemplate($templatePath, 'login.ini');
		if($this->_request->isPost()){
			$auth = new Myh_System_Auth();
			$options['tblName'] = 'admin_user';
			$options['where'] 	= 'is_active=1';
			if($auth->login($this->_arrParams, $options)){
				$info = new Myh_System_Info();
				$info->createInfo('admin_user');
				$this->_redirect('/admin/index/index');
			}else{
				$this->view->errors = $auth->getMessageError();
			}
		}
	}
	public function logoutAction()
	{
		$auth = new Myh_System_Auth();
		$auth->logout();
		$info = new Myh_System_Info();
		$info->destroyInfo();
		$this->_redirect('/admin/index/index');
	}
}